home *** CD-ROM | disk | FTP | other *** search
- DefInt A-Z
-
- 'Device Control Block (DCB) type structure used by the
- 'Windows API functions GetCommState and SetCommState
- '
- Type DCB_Type
- Id As String * 1 ' Port Id from OpenComm
- BaudRate As Integer ' Baud Rate
- ByteSize As String * 1 ' Data Bit Size (4 to 8)
- Parity As String * 1 ' Parity
- StopBits As String * 1 ' Stop Bits
- RlsTimeOut As Integer ' Carrier Detect Time "CD"
- CtsTimeOut As Integer ' Clear-to-Send Time
- DsrTimeOut As Integer ' Data-Set-Ready Time
- ModeControl As Integer ' Mode Control Bit Fields
- XonChar As String * 1 ' XON character
- XoffChar As String * 1 ' XOFF character
- XonLim As Integer ' Min characters in buffer before XON is sent
- XoffLim As Integer ' Max characters in buffer before XOFF is send
- peChar As String * 1 ' Parity Error Character
- EofChar As String * 1 ' EOF/EOD character
- EvtChar As String * 1 ' Event character
- TxDelay As Integer ' Reserved/Not Used
- End Type
- '
- 'Type structure used by the GetCommError API function
- '
- Type COMSTAT_Type
- ModeControl As String * 1
- cbInQue As Integer
- cbOutQue As Integer
- End Type
- '
- 'Windows COM related API function declarations
- '
- Declare Function OpenComm Lib "USER" (ByVal lpCommName As Any, ByVal wInQueue, ByVal wOutQueue)
- Declare Function CloseComm Lib "USER" (ByVal nCid)
- Declare Function ReadComm Lib "USER" (ByVal nCid, ByVal lpBuf As Any, ByVal nSize)
- Declare Function WriteComm Lib "USER" (ByVal nCid, ByVal lpBuf As Any, ByVal nSize)
- Declare Function BuildCommDCB Lib "USER" (ByVal lpDef As Any, lpDCB As DCB_Type)
- Declare Function GetCommState Lib "USER" (ByVal nCid, DCB As DCB_Type)
- Declare Function SetCommState Lib "USER" (DCB As DCB_Type)
- Declare Function SetCommEventMask Lib "USER" (ByVal nCid, ByVal nEvtMask) As Long
- Declare Function GetCommEventMask Lib "USER" (ByVal nCid, ByVal nEvtMask)
- Declare Function GetCommError Lib "USER" (ByVal nCid, COMSTAT As COMSTAT_Type)
- Declare Function FlushComm Lib "USER" (ByVal nCid, ByVal nQueue)
- '
- 'Possible return values (error codes) from the Windows API function OpenComm
- '
- Global Const IE_BADID = -1 ' Invalid or unsupported id
- Global Const IE_OPEN = -2 ' Device Already Open
- Global Const IE_NOPEN = -3 ' Device Not Open
- Global Const IE_MEMORY = -4 ' Unable to allocate queues
- Global Const IE_DEFAULT = -5 ' Error in default parameters
- Global Const IE_HARDWARE = -10 ' Hardware Not Present
- Global Const IE_BYTESIZE = -11 ' Illegal Byte Size
- Global Const IE_BAUDRATE = -12 ' Unsupported BaudRate
- '
- 'Possible return values from the Windows API function GetCommError
- '
- Global Const CE_BREAK = &H10
- Global Const CE_CTSTO = &H20
- Global Const CE_DNS = &H800
- Global Const CE_DSRTO = &H40
- Global Const CE_FRAME = &H8
- Global Const CE_IOE = &H400
- Global Const CE_MODE = &H8000
- Global Const CE_OOP = &H1000
- Global Const CE_OVERRUN = &H2
- Global Const CE_PTO = &H200
- Global Const CE_RLSDTO = &H80
- Global Const CE_RXOVER = &H1
- Global Const CE_RXPARITY = &H4
- Global Const CE_TXFULL = &H100
- '
- 'Possible communications events used with the API functions GetCommEventMask and SetCommEventMask
- '
- Global Const EV_RXCHAR = &H1 'Set when a character is received and placed in the input buffer
- Global Const EV_RXFLAG = &H2 'Set when the event character is received and placed in the input buffer
- Global Const EV_TXEMPTY = &H4 'Set when the last character in the transmit queue is sent
- Global Const EV_CTS = &H8 'Set when the clear-to-send (CTS) signal changes state
- Global Const EV_DSR = &H10 'Set when the data-set-ready (DSR) signal changes state
- Global Const EV_RLSD = &H20 'Set when the receive-line-signal-detect (RLSD or CD) signal changes state
- Global Const EV_BREAK = &H40 'Set when a break is deteced on input
- Global Const EV_ERR = &H80 'Set when a line-status error (CE_FRAME, CE_OVERRUN, CE_RXPARITY) occurs
- Global Const EV_RING = &H100 'Set when a ring indicator is detected
- Global Const EV_PERR = &H200 'Set when a printer error is detected (CE_DNS, CE_IOE, CE_LOOP, CE_PTO)
- Global Const EV_ALL = &H3FF 'Value when all of the above event masks are set
- '
- 'Possible parity settings for the Parity field in the DCB_Type type structure
- '
- Global Const NOPARITY = 0
- Global Const ODDPARITY = 1
- Global Const EVENPARITY = 2
- '
- 'Possible stop bit settings for the StopBits field in the DCB_Type type structure
- '
- Global Const ONESTOPBIT = 0
- Global Const ONE5STOPBITS = 1 '1.5 STOP BITS
- Global Const TWOSTOPBITS = 2
- '
- 'Boolean constants
- '
- Global Const False = 0
- Global Const True = Not False
- '
- 'Default message box caption
- '
- Global Const DefMsgCaption = "Communications Demo"
- '
- 'Variables representing carriage return and carriage return linefeed respectively
- '
- Global CR As String
- Global CRLF As String
-
-